package com.agv.core.lectorDeGlobalizadoresImpl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import com.agv.core.lectorDeGlobalizador.ILectorBca;

public class LectorBca implements ILectorBca{

	public ArrayList<HashMap<String, String>> bca(ArrayList<String> list)
			throws Exception {

		ArrayList<HashMap<String, String>> clientes = new ArrayList<HashMap<String, String>>();

		for (int i = 0; i < list.size(); i++) {
			HashMap<String, String> data = new HashMap<String, String>();

			String[] linea = list.get(i).split("\\|");

			// for (int j = 0; j < linea.length; j++) {
			// System.out.println("linea "+j+" "+linea[j]);
			// }

			data.put("DK", linea[0]);
			data.put("RECORD", linea[1]);
			data.put("PASAJERO", linea[2]);
			data.put("BOLETO", linea[3]);
			data.put("TARIFA BASE", linea[4]);
			data.put("TUA", linea[5]);
			data.put("IVA", linea[6]);
			data.put("TOTAL", linea[7]);
			data.put("RUTA DEPARTURE", linea[8]);
			data.put("RUTA ARRIVAL", linea[9]);
			data.put("DEPARTURE DATE", linea[10]);
			data.put("ARRIVAL DATE", linea[11]);
			data.put("CLASE", linea[12]);
			data.put("PROVEEDOR", linea[13]);
			data.put("AGENTE", linea[14]);
			data.put("FORMA DE PAGO", linea[15]);
			data.put("INDICADOR DE RUTA", linea[16]);

			clientes.add(data);

		}

		// forma de leer el array
		for (int i = 0; i < clientes.size(); i++) {

			System.out.println(">>>>>>>>>>>>>>>>>cliente " + i);
			Iterator it = clientes.get(i).entrySet().iterator();
			while (it.hasNext()) {
				Map.Entry elem = (Map.Entry) it.next();
				System.out.println(elem.getKey() + "\t\t\t " + elem.getValue());

			}
		}
		return clientes;
	}

	public ArrayList<HashMap<String, String>> leer(ArrayList<String> list)
			throws Exception {
		return bca(list);
	}
}
